module MarketDataTest

open System
open System.Reactive.Linq 

open Trading
open Trading.IBApi
open PriceTest

open com.ib.client

let mock() = 
    {
        new IBrokerGateway with
            member this.ConnectionInfo = "broker mock"
            member this.Errors = Observable.Empty()

            member this.Ticks(_) =  
                let prices = 
                    Seq.initInfinite (
                        fun i -> if i % 2 = 0 then Tick.BidPrice (double i) else Tick.AskPrice (double i)) 
                let ticks = Observable.Interval(period = TimeSpan.FromSeconds(1.0))
                ticks.Zip(prices, resultSelector = fun _ price -> price)

            member this.ContractDetails _ _ = undefined
            member this.PlaceOrder(contract, order) = undefined
            member this.HistoricalData(_,_,_,_,_,_) = undefined
            member this.RealTimeBars(_,_,_) = undefined
    }